﻿@*@model List<BathhouseService.Models.SqlModels.Notice>*@
@{
    ViewData["Title"] = "公告列表";
    Layout = "~/Areas/WX/Views/Shared/_Layout.cshtml";
}


<header class="hui-header">
    <div id="hui-back"></div>
    <h1>公告列表</h1>
</header>

<div class="hui-wrap">


    <div id="refreshContainer" class="hui-refresh">
        <div class="hui-refresh-icon"></div>
        <div class="hui-refresh-content hui-list" id="con">
            <ul id="list"></ul>
        </div>
    </div>
    
</div>


<div class="hui-fooer-line"></div>
<div id="hui-footer">
    <a href="/WX/Home/Index" id="nav-home">
        <div class="hui-footer-icons hui-icons-home"></div>
        <div class="hui-footer-text">首页</div>
    </a>
    <a href="/WX/Home/PayBills" id="nav-news">
        <div class="hui-footer-icons hui-icons-news"></div>
        <div class="hui-footer-text">支付</div>
    </a>
    <div style="width:20%; text-align:center;" class="hui-fl">
        <img src="~/images/jmlogo.jpg" height="44" onclick="hui.back();" />

    </div>
    <a href="/WX/Home/NoticeList" id="nav-forum">
        <div class="hui-footer-icons hui-icons-forum"></div>
        <div class="hui-footer-text">公告</div>
    </a>
    <a href="/WX/Home/PersonalPage" id="nav-my">
        <div class="hui-footer-icons hui-icons-my"></div>
        <div class="hui-footer-text">我的</div>
    </a>
</div>



@section Scripts{

    <script src="~/HUI-master/js/hui-refresh-load-more.js"></script>
    <script>
        var page = 1;
        hui.refresh('#refreshContainer', refresh);
        hui.loadMore(getMore);
        //加载更多
        function getMore() {
            hui.get(
                '/WX/Home/NoticeListJson?page=' + page,
                function (res) {

                    
                    var jsonres = JSON.parse(res)
                    var data = jsonres.Data;
                    if (data.length == 0) {                      
                        hui.endLoadMore(true, '已经到头了...');
                        return false;
                    }                                      
                    for (var i = 0; i < data.length; i++) {
                        var li = document.createElement('li');
                        li.innerHTML = '<a href="/WX/Home/NoticeDetailed/' + data[i].ID + '">' +
                            ' <div class="hui-list-text">' +
                            '<div class="hui-list-text-content">' +
                            data[i].Title +
                            '</div>' +
                            '<div class="hui-list-info">' +
                            '查看 <span class="hui-icons hui-icons-right"></span>' +
                            '</div>' +
                            '</div>' +
                            '</a>';
                        hui(li).appendTo('#list');
                    }
                    page++;
                    hui.endLoadMore();
                }
            );
        }


        function refresh() {
            hui.loading('加载中...');
            hui.get(
                '/WX/Home/NoticeListJson?page=1',
                function (res) {                   
                    hui.closeLoading();
                    var jsonres = JSON.parse(res)
                    var data = jsonres.Data;


                    if (data.length > 0) {
                        var html = '';
                        for (var i = 0; i < data.length; i++) {
                            html += '<li>' +
                                '<a href="/WX/Home/NoticeDetailed/' + data[i].ID + '">' +
                                ' <div class="hui-list-text">' +
                                '<div class="hui-list-text-content">' +
                                data[i].Title +
                                '</div>' +
                                '<div class="hui-list-info">' +
                                '查看 <span class="hui-icons hui-icons-right"></span>' +
                                '</div>' +
                                '</div>' +
                                '</a>' +
                                '</li>';
                        }
                        page = 2;
                        hui('#list').html(html);
                        //结束刷新
                        hui.endRefresh();
                        //重置加载更多状态
                        hui.resetLoadMore();
                    } else {
                        var html = '<div class="hui-common-title" style="margin-top:15px;">' +
                            '<div class="hui-common-title-line" ></div >'+
                                '<div class="hui-common-title-txt">暂无公告</div>'+
                                '<div class="hui-common-title-line"></div>'+
                             '</div>';
                        hui('#con').html(html);
                        //结束刷新
                        hui.endRefresh();
                        //重置加载更多状态
                        //hui.resetLoadMore();
                        hui('#hui-load-more').hide();
                    }

                    
                },
                function () {
                    hui.closeLoading();
                    hui.upToast('连接服务器失败！');
                    hui.endRefresh();
                }
            );
        }

    </script>
}

